<template >
<view class="container">
     <div class="logo_img">
        <img src="/static/images/logo.png">
      </div>
      <div>
            <div  class="input-sname" >
                <input v-model=" mobile" type='phone' maxlength="11" placeholder="请输入手机号" label="用户名"> 
            </div> 
           <div class="input-code">
                <input placeholder="请输入验证码" v-model=" smsCode" label="验证码" >  
                  <div   class="from-Code-btn">
                    <span v-if="sendAuthCode" class="auth_text auth_text_blue" @click="CodeBtn" style='cursor:pointer'>获取验证码(120)</span>
                    <span v-else class="auth_text" style='cursor:pointer'> <span class="auth_text_blue" style='cursor:pointer'>{{authtime}} </span> 秒之重新发送验证码</span>
                  </div>
           </div>
           
      </div>
      <div class="btn_login" @click='login'>
      <span class="button">绑定</span>  
        </div>
</view>
</template> 

<script>
// import api from '@/utils/api'
import wx from 'wx'
 
import util from '@/utils/util'
import api from '@/utils/api'
export default {
  data () {
    return {
      status: false,
      orderId: 0,
      mobile:'',
      smsCode:'',
      authtime:120,
      sendAuthCode: true,
    }
  },
  async mounted () {
 
  },
  methods: {
   async login(){
     if ( this.mobile.length<11) {
        wx.showToast({
                title: '请先输入完整手机号',
                icon: 'none'
              });
         return false     
      } ;
      if(this.smsCode==''){
            wx.showToast({
                title: '请先输入验证码',
                icon: 'none'
              });
         return false    

      }
            let data=JSON.stringify({ "mobile": this.mobile, "smsCode": this.smsCode, "userType": "1", "storeType": "2" ,"longitude": "", "latitude": "" })
              const res = await api.SmsLogin({"data":data});
            wx.setStorageSync('token', res.data.token );
    },
   async  CodeBtn() {
   
  
      if ( this.mobile.length<11) {
          wx.showToast({
                title: '请先输入完整手机号',
                icon: 'none'
              })
              return false;
      }
      let data=JSON.stringify({"mobile":this.mobile})
 
      const res = await api.GetVerSmsCode({"data":data});
    
      if (res.status = '0'){
        this.sendAuthCode = false;
        this.authtime = 120;
        this.auth_timetimer = setInterval(()=>{
          this.authtime--;
          if(this.authtime<=0){
            this.sendAuthCode = true;
            clearInterval(this.auth_timetimer);
          }
          }, 1000);
        }
   
     
     
        
    
    },
     
  },
  // 原生的分享功能
  onShareAppMessage: function () {
    return {
      title: 'dfcShop',
      desc: '大风车商场',
      path: '/pages/pay/payResult'
    }
  }
}
</script>

<style lang='scss' scoped>
page {
  min-height: 100%;
  width: 100%;
  background: #fff;
}
.input-sname{
 
  border-bottom: 1px solid rgba(51,51,51,0.2);
  font-size: 13px;
  width: 80vw;;
  margin: 0 auto;
  
  height: 40px;;
  input{
    line-height: 40px;
    padding-left:4vw;
    height: 40px;
  }
}
.input-code{
  
  border-bottom: 1px solid rgba(51,51,51,0.2);
  font-size: 13px;
  width: 80vw;;
  margin: 0 auto;
  margin-top: 20px;
  height: 40px;;
  input{
    float: left;
    width: 25vw;;
    line-height: 40px;
    height: 40px;;
      padding-left:4vw;
      }

}
 .from-Code-btn{
  height: 34px;
  line-height: 34px;
  border: 0;
  border-radius: 4px;
  background-color:#FF4444;
  color: #fff;
  font-size: 12px;
  float: right;
  margin-top: 3px;
  padding: 0 10px;
  span{
    height: 30px;;
  }
}
.container {
  height: 100%;
  background: #fff;
}
 .logo_img{
   img{
      width: 85px;
      height: 85px;
      display: block;
      margin: 13.333vw auto 8vw;
   }
 }
   .btn_login{
    text-align: center;
    margin: 15px auto;
    .button{
      width: 264px;
      height: 39px;
      background-color:#FF4444;
      border: 0;
      border-radius:4px;
      box-shadow:0px 13px 57px 0px #f8afb3;
      line-height: 39px;

      font-size: 15px;
      color: #fff;
      font-weight: 500;
      display: block;
    }
  }

</style>
